/*
 * @FilePath: /tads/server/app/business/service/dto/tactics.go
 * @Author: wnina0x0
 * @Date: 2025-04-14 09:52:12
 * @Description:
 *
 * 版权信息 : 2025 by wnina0x0, All Rights Reserved.
 */
package dto

import (
	"tads/server/app/business/models"
	"time"
)

type TacticsGetRequests struct {
	GetPage
	TacticsName string `form:"tactics_name"`
}

type TacticsInsetRequests struct {
	TacticsName               string `json:"tactics_name"`
	TacticsDesc               string `json:"tactics_desc"`
	TacticsTypeId             uint   `json:"tactic_type_id"`
	TacticsDbusTypeText       string `json:"tactic_bus_type_text"`
	TacticsAttackMethodIdText string `json:"tactic_attack_method_id_text"`
	TacticsSceneId            uint   `json:"tactic_scene_id"`
	Creator                   string `json:"creator"`
}

func (s *TacticsInsetRequests) Generate(models *models.Tactics) {
	models.TacticsName = s.TacticsName
	models.TacticsDesc = s.TacticsDesc
	models.TacticsTypeId = s.TacticsTypeId
	models.TacticsDbusTypeText = s.TacticsDbusTypeText
	models.TacticsAttackMethodIdText = s.TacticsAttackMethodIdText
	models.Creator = s.Creator
	models.CreateTime = time.Now()
	models.Updater = s.Creator
	models.UpdateTime = time.Now()
}

type TacticsGetResponse struct {
	Total       int              `json:"total"`        // 总记录数
	TotalPages  int              `json:"total_pages"`  // 总页数
	CurrentPage int              `json:"current_page"` // 当前页
	PageSize    int              `json:"page_size"`    // 每页数量
	Data        []TacticsGetData `json:"data"`         // 实际数据
}

type TacticsGetData struct {
	ID                        uint     `json:"id"`
	TacticsName               string   `json:"tactics_name"`
	TacticsDesc               string   `json:"tactics_desc"`
	TacticsTypeId             uint     `json:"tactic_type_id"`
	TacticsDbusTypeText       []string `json:"tactic_bus_type_text"`
	TacticsAttackMethodIdText []string `json:"tactic_attack_method_id_text"`
	IsDeleted                 bool     `json:"is_deleted"`
}

func (p *TacticsGetResponse) NewPageResponse(total int, req *TacticsGetRequests, data []TacticsGetData) *TacticsGetResponse {
	totalPages := total / req.PageSize
	if total%req.PageSize > 0 {
		totalPages++
	}

	return &TacticsGetResponse{
		Total:       total,
		TotalPages:  totalPages,
		CurrentPage: req.PageIndex,
		PageSize:    req.PageSize,
		Data:        data,
	}
}

func (p *TacticsGetResponse) GetData(c *models.Tactics, b []string, a []string) *TacticsGetData {
	return &TacticsGetData{
		ID:                        c.ID,
		TacticsName:               c.TacticsName,
		TacticsDesc:               c.TacticsDesc,
		TacticsTypeId:             c.TacticsTypeId,
		TacticsDbusTypeText:       b,
		TacticsAttackMethodIdText: a,
		IsDeleted:                 c.IsDeleted,
	}
}

type TacticsStatusRequests struct {
	ID     uint `json:"id"`
	Status bool `json:"status"`
}

type TacticsUpdateRequests struct {
	ID                        uint   `json:"id"`
	TacticsName               string `json:"tactics_name"`
	TacticsDesc               string `json:"tactics_desc"`
	TacticsTypeId             uint   `json:"tactic_type_id"`
	TacticsDbusTypeText       string `json:"tactic_bus_type_text"`
	TacticsAttackMethodIdText string `json:"tactic_attack_method_id_text"`
}

func (s *TacticsUpdateRequests) Generate(models *models.Tactics) {
	models.TacticsName = s.TacticsName
	models.TacticsDesc = s.TacticsDesc
	models.TacticsTypeId = s.TacticsTypeId
	models.TacticsDbusTypeText = s.TacticsDbusTypeText
	models.TacticsAttackMethodIdText = s.TacticsAttackMethodIdText
	models.Updater = "admin"
	models.UpdateTime = time.Now()
}
